{% extends "admin/base.html" %}

{% block title %}儀表板 - 管理後台{% endblock %}

{% block page_title %}儀表板{% endblock %}

{% block content %}
<!-- 统计卡片 -->
<div class="row">
    <div class="col-md-3">
        <div class="stat-card">
            <div class="stat-icon">
                <i class="fas fa-newspaper"></i>
            </div>
            <h3>{{ news_count }}</h3>
            <p class="text-muted mb-0">資訊文章</p>
        </div>
    </div>
    <div class="col-md-3">
        <div class="stat-card">
            <div class="stat-icon">
                <i class="fas fa-briefcase"></i>
            </div>
            <h3>{{ cases_count }}</h3>
            <p class="text-muted mb-0">成功案例</p>
        </div>
    </div>
    <div class="col-md-3">
        <div class="stat-card">
            <div class="stat-icon">
                <i class="fas fa-envelope"></i>
            </div>
            <h3>{{ contacts_count }}</h3>
            <p class="text-muted mb-0">未處理諮詢</p>
        </div>
    </div>
    <div class="col-md-3">
        <div class="stat-card">
            <div class="stat-icon">
                <i class="fas fa-eye"></i>
            </div>
            <h3>{{ visits_count }}</h3>
            <p class="text-muted mb-0">今日訪問</p>
        </div>
    </div>
</div>

<!-- 最新咨询 -->
<div class="row mt-4">
    <div class="col-md-6">
        <div class="card">
            <div class="card-header">
                <h5 class="card-title mb-0">最新諮詢</h5>
            </div>
            <div class="card-body">
                <div class="table-responsive">
                    <table class="table">
                        <thead>
                            <tr>
                                <th>姓名</th>
                                <th>電話</th>
                                <th>時間</th>
                                <th>狀態</th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for contact in latest_contacts %}
                            <tr>
                                <td>{{ contact.name }}</td>
                                <td>{{ contact.phone }}</td>
                                <td>{{ contact.created_at.strftime('%Y-%m-%d %H:%M') }}</td>
                                <td>
                                    {% if contact.status == 'pending' %}
                                        <span class="badge bg-warning">待處理</span>
                                    {% else %}
                                        <span class="badge bg-success">已處理</span>
                                    {% endif %}
                                </td>
                            </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    
    <!-- 最新文章 -->
    <div class="col-md-6">
        <div class="card">
            <div class="card-header">
                <h5 class="card-title mb-0">最新文章</h5>
            </div>
            <div class="card-body">
                <div class="table-responsive">
                    <table class="table">
                        <thead>
                            <tr>
                                <th>標題</th>
                                <th>分類</th>
                                <th>發布時間</th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for article in latest_news %}
                            <tr>
                                <td>{{ article.zh_title }}</td>
                                <td>{{ article.category }}</td>
                                <td>{{ article.publish_date.strftime('%Y-%m-%d') }}</td>
                            </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %} 